﻿using System;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using System.ServiceModel;
using System.Windows;
using System.Windows.Controls;
using DemoInterop;
using WcfDynamicProxy;

namespace DemoClient
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void Run_Click(object sender, RoutedEventArgs e)
        {
            var factory = new WcfQueryFactory<IService>("DemoWcfServiceEndpointName", TaskManager.Instance);
            
            factory.ExecuteQuery(s => s.GetData(4))
                .ObserveOn(DispatcherScheduler.Current)
                   .Subscribe(
                        res => MessageBox.Show("Result: " + res),
                        err => MessageBox.Show("Error:" + err)
                );
        }
    }
}
